<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>xiaxuchen的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="xiaxuchen的博客">
<meta property="og:url" content="http://yoursite.com/page/2/index.html">
<meta property="og:site_name" content="xiaxuchen的博客">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="xiaxuchen">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="./atom.xml" title="xiaxuchen的博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="./css/style.css">

<meta name="generator" content="Hexo 5.0.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="./" id="logo">xiaxuchen的博客</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="./">Home</a>
        
          <a class="main-nav-link" href="./archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="./atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-前端/vue 组件" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/vue%20%E7%BB%84%E4%BB%B6/" class="article-date">
  <time datetime="2020-08-07T15:08:02.764Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="vue-组件"><a href="#vue-组件" class="headerlink" title="vue 组件"></a>vue 组件</h1><ol>
<li>如果组件无法按照规范放在某些html标签中可以是用is属性将正常子标签转换为组件，如ul&gt;li：</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">    直接放置某组件无效，因为ul下面必须是li</span></span><br><span class="line"><span class="comment">    &lt;组件名&gt;&lt;/组件名&gt;</span></span><br><span class="line"><span class="comment">    --&gt;</span></span><br><span class="line">    <span class="comment">&lt;!--可以这样，渲染时会将li当做你的组件渲染--&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span> <span class="attr">is</span>=<span class="string">&quot;组件名&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>当然还有tr&gt;td,select&gt;option等</p>
<ol start="2">
<li><p>通过ref、$refs操作dom</p>
<p>当需要操作dom的时候，可以给想要操作的标签指定一个ref属性，如·<code>&lt;div ref=&#39;div&#39;&gt;&lt;/div&gt;</code>,则可以在vue中使用<strong>this.$refs.div</strong>操作</p>
</li>
<li><p>非父子组件传值(发布订阅模式)</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">Vue.prototype.bus = <span class="keyword">new</span> Vue()</span><br><span class="line">Vue.component(<span class="string">&#x27;bor1&#x27;</span>,&#123;</span><br><span class="line">    template:<span class="string">&#x27;&lt;div @click=&quot;handleClick&quot;&gt;hellp&lt;/div&gt;&#x27;</span>,</span><br><span class="line">    methods:&#123;</span><br><span class="line">        handleClick()&#123;</span><br><span class="line">            <span class="comment">//发布事件</span></span><br><span class="line">            <span class="built_in">this</span>.bus.$emit(<span class="string">&#x27;click&#x27;</span>,<span class="string">&#x27;hello&#x27;</span>)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br><span class="line">Vue.component(<span class="string">&#x27;bor2&#x27;</span>,&#123;</span><br><span class="line">    template:<span class="string">&#x27;&lt;div&gt;hellp&lt;/div&gt;&#x27;</span>,</span><br><span class="line">    mounted()&#123;</span><br><span class="line">        <span class="comment">//订阅</span></span><br><span class="line">        <span class="built_in">this</span>.bus.$on(<span class="string">&#x27;click&#x27;</span>,<span class="function">(<span class="params">data</span>)=&gt;</span>&#123;</span><br><span class="line">            <span class="built_in">console</span>.log(data)</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ol start="3">
<li><p>动态组件和v-once</p>
<p>可以通过动态组件将一个组件进行切换</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- html --&gt;</span><br><span class="line">&lt;component :is=<span class="string">&quot;type&quot;</span> &gt;&lt;/component&gt;</span><br><span class="line">&lt;button @click=<span class="string">&quot;handleClick&quot;</span>&gt;切换&lt;/button&gt;</span><br><span class="line">&lt;!-- js --&gt;</span><br><span class="line"><span class="keyword">const</span> vm = <span class="keyword">new</span> Vue(&#123;</span><br><span class="line">    data:&#123;</span><br><span class="line">        type:<span class="string">&#x27;el-col&#x27;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    method:&#123;</span><br><span class="line">    <span class="comment">/*切换*/</span></span><br><span class="line">        handleClick()&#123;</span><br><span class="line">            <span class="built_in">this</span>.type = (<span class="built_in">this</span>.type === <span class="string">&#x27;el-button&#x27;</span>)? <span class="string">&#x27;el-col&#x27;</span> : <span class="string">&#x27;el-button&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<p>在切换中组件会销毁，如果不想组件销毁可以在组件的模板中添加v-once属性<code>&lt;组件模板 v-once&gt;&lt;/组件模板&gt;</code>，组件切换时不会销毁，仍在内存中</p>
</li>
</ol>
</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E5%89%8D%E7%AB%AF/vue%20%E7%BB%84%E4%BB%B6/" data-id="ckdkdagu8000cvout290te5ul" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-前端/vue 动画" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/vue%20%E5%8A%A8%E7%94%BB/" class="article-date">
  <time datetime="2020-08-07T15:08:02.760Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="vue-动画"><a href="#vue-动画" class="headerlink" title="vue 动画"></a>vue 动画</h1><p>​    使用transition标签</p>
<p>​    <code>&lt;transition name=&quot;fade&quot;&gt;内部有显示隐藏&lt;/transition&gt;</code></p>
<ol>
<li><p>进入动画</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20191206123157919.png" alt="image-20191206123157919"></p>
<p>在enter中写初始样式，在enter-active中写transition，在enter-to中写结束样式</p>
</li>
<li><p>离开动画</p>
</li>
</ol>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20191206123102440.png" alt="image-20191206123102440"></p>
<p>在leave中写初始样式，在leave-active中写transition，在leave-to中写结束样式</p>
<ol start="3">
<li><p>animated动画库的使用</p>
<ol>
<li>引入css文件</li>
<li>在transition标签上指定enter-active-class、enter-leave-class</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!--必须有animated--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">transition</span> <span class="attr">enter-active-class</span>=<span class="string">&quot;animated swing&quot;</span> <span class="attr">enter-leave-class</span>=<span class="string">&quot;animated shake&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">transition</span>&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>vue中多个元素的显示隐藏</p>
<p>需要给多个元素不同的key使之不复用dom即可</p>
<p>可以设置mode为in-out或out-in先进入还是先隐藏</p>
</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E5%89%8D%E7%AB%AF/vue%20%E5%8A%A8%E7%94%BB/" data-id="ckdkdagu7000bvout7yse6p32" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-前端/vue + webpack简单学习" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E5%89%8D%E7%AB%AF/vue%20+%20webpack%E7%AE%80%E5%8D%95%E5%AD%A6%E4%B9%A0/" class="article-date">
  <time datetime="2020-08-07T15:08:02.739Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="Vue-Webpack的简单学习"><a href="#Vue-Webpack的简单学习" class="headerlink" title="Vue + Webpack的简单学习"></a>Vue + Webpack的简单学习</h2><h3 id="一、WebPack新建工程"><a href="#一、WebPack新建工程" class="headerlink" title="一、WebPack新建工程"></a>一、WebPack新建工程</h3><ol>
<li><p>使用命令创建工程</p>
<figure class="highlight cmd"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">npm init  // 初始化为npm工程,这样就有了包管理</span><br><span class="line">npm i webpack vue vue-loader // 安装webpack和vue的依赖</span><br><span class="line">// 发现警告 npm WARN vue-loader@<span class="number">15</span>.<span class="number">8</span>.<span class="number">3</span> requires a peer of css-loader@* but none is installed. You must install peer dependencies yourself.</span><br><span class="line">// 按要求安装依赖</span><br><span class="line">npm i css-loader</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="2">
<li><p>在根路径创建webpack.config.js</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">&#x27;path&#x27;</span>) <span class="comment">// nodejs基础包，用于处理路径，如拼接</span></span><br><span class="line"><span class="keyword">const</span> VueLoaderPlugin = <span class="built_in">require</span>(<span class="string">&#x27;vue-loader/lib/plugin&#x27;</span>); <span class="comment">// 必须的插件，用于加载.vue文件格式</span></span><br><span class="line"><span class="keyword">const</span> HtmlWebpackPlugin = <span class="built_in">require</span>(<span class="string">&#x27;html-webpack-plugin&#x27;</span>)</span><br><span class="line"><span class="keyword">const</span> webpack = <span class="built_in">require</span>(<span class="string">&#x27;webpack&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> isDev = process.env.NODE_ENV === <span class="string">&#x27;development&#x27;</span> <span class="comment">// 获取环境变量</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> config = &#123;</span><br><span class="line">    target: <span class="string">&#x27;web&#x27;</span>,</span><br><span class="line">    entry: path.join(__dirname, <span class="string">&#x27;src/main.js&#x27;</span>), <span class="comment">// 入口js，通过入口的内容以及他的依赖进行打包</span></span><br><span class="line">    output: &#123; <span class="comment">// 输出:入口打包的内容输出到哪里</span></span><br><span class="line">        filename: <span class="string">&#x27;bundle.js&#x27;</span>,</span><br><span class="line">        path: path.join(__dirname, <span class="string">&#x27;dist&#x27;</span>)</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="built_in">module</span>: &#123;</span><br><span class="line">        rules: [&#123; <span class="comment">// 配置loader处理的文件类型，因为原本只支持.js类型，通过loader机制进行扩展，以支持更多类型</span></span><br><span class="line">                test: <span class="regexp">/\.vue$/</span>,</span><br><span class="line">                loader: <span class="string">&#x27;vue-loader&#x27;</span></span><br><span class="line">            &#125;, &#123;</span><br><span class="line">                test: <span class="regexp">/\.css$/</span>,</span><br><span class="line">                use: [</span><br><span class="line">                    <span class="string">&#x27;style-loader&#x27;</span>,</span><br><span class="line">                    <span class="string">&#x27;css-loader&#x27;</span></span><br><span class="line">                ]</span><br><span class="line">            &#125;,</span><br><span class="line">            &#123;</span><br><span class="line">                test: <span class="regexp">/\.styl$/</span>,</span><br><span class="line">                use: [</span><br><span class="line">                    <span class="string">&#x27;style-loader&#x27;</span>,</span><br><span class="line">                    <span class="string">&#x27;css-loader&#x27;</span>,</span><br><span class="line">                    <span class="string">&#x27;stylus-loader&#x27;</span></span><br><span class="line">                ]</span><br><span class="line">            &#125;, &#123;</span><br><span class="line">                test: <span class="regexp">/\.(jpeg|png|jpg|svg|gif)$/</span>,</span><br><span class="line">                use: [&#123;</span><br><span class="line">                    loader: <span class="string">&#x27;url-loader&#x27;</span>, <span class="comment">// 将图片转换为base64直接放在js中，无需额外加载</span></span><br><span class="line">                    options: &#123; <span class="comment">//配置小于1024kb即可转换base64</span></span><br><span class="line">                        limit: <span class="number">1024</span>,</span><br><span class="line">                        name: <span class="string">&#x27;[name].[ext]&#x27;</span></span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;]</span><br><span class="line">            &#125;</span><br><span class="line">        ]</span><br><span class="line">    &#125;,</span><br><span class="line">    plugins: [ <span class="comment">// 插件</span></span><br><span class="line">        <span class="keyword">new</span> HtmlWebpackPlugin(),</span><br><span class="line">        <span class="keyword">new</span> VueLoaderPlugin(),</span><br><span class="line">        <span class="comment">// 将环境变量暴露到项目中，使得内容可以分模式编译</span></span><br><span class="line">        <span class="keyword">new</span> webpack.DefinePlugin(&#123;</span><br><span class="line">            <span class="string">&#x27;process.env&#x27;</span>: &#123;</span><br><span class="line">                NODE_ENV: isDev ? <span class="string">&#x27;&quot;development&quot;&#x27;</span> : <span class="string">&#x27;&quot;production&quot;&#x27;</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 如果是开发环境则添加服务器配置</span></span><br><span class="line"><span class="keyword">if</span> (isDev) &#123;</span><br><span class="line">    <span class="comment">// 不直接使用编译后的代码，而是展示源码映射，方便调试</span></span><br><span class="line">    config.devTool = <span class="string">&#x27;#cheap-module-eval-source-map&#x27;</span></span><br><span class="line">    config.devServer = &#123;</span><br><span class="line">            port: <span class="number">8001</span>,</span><br><span class="line">            host: <span class="string">&#x27;0.0.0.0&#x27;</span>, <span class="comment">// 本机ip和127.0.0.1都可以访问</span></span><br><span class="line">            overlay: &#123;</span><br><span class="line">                errors: <span class="literal">true</span> <span class="comment">// 遇到错误都打印出来</span></span><br><span class="line">            &#125;,</span><br><span class="line">            <span class="comment">// 开启热更新</span></span><br><span class="line">            hot: <span class="literal">true</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 添加热更新插件</span></span><br><span class="line">    config.plugins.push(</span><br><span class="line">        <span class="keyword">new</span> webpack.HotModuleReplacementPlugin()</span><br><span class="line">    )</span><br><span class="line">    config.plugins.push(</span><br><span class="line">        <span class="keyword">new</span> webpack.NoEmitOnErrorsPlugin()</span><br><span class="line">    )</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="built_in">module</span>.exports = config</span><br></pre></td></tr></table></figure>

<p>其中的main.js如下:</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">&#x27;vue&#x27;</span></span><br><span class="line"><span class="keyword">import</span> App <span class="keyword">from</span> <span class="string">&#x27;./app.vue&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 创建绑定的元素</span></span><br><span class="line"><span class="keyword">const</span> root = <span class="built_in">document</span>.createElement(<span class="string">&#x27;div&#x27;</span>);</span><br><span class="line"><span class="built_in">document</span>.body.appendChild(root)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 创建vue对象并将内容进行渲染</span></span><br><span class="line"><span class="keyword">new</span> Vue(&#123;</span><br><span class="line">    render: <span class="function">(<span class="params">h</span>) =&gt;</span> h(App)</span><br><span class="line">&#125;).$mount(root)</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="3">
<li><p>webpack-dev-server</p>
<p>安装依赖</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm i webpack-dev-server </span><br><span class="line">npm i cross-env &#x2F;&#x2F; 设置环境变量，因为在不同平台原本需要不同的命令，使用这个可以统一</span><br></pre></td></tr></table></figure>

<p>package.json配置运行命令</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 使用cross-env 配置环境变量</span><br><span class="line">&quot;scripts&quot;: &#123;</span><br><span class="line">       &quot;build&quot;: &quot;cross-env NODE_ENV&#x3D;production webpack --config webpack.config.js&quot;,</span><br><span class="line">       &quot;dev&quot;: &quot;cross-env NODE_ENV&#x3D;development webpack-dev-server --config webpack.config.js&quot;</span><br><span class="line">   &#125;,</span><br></pre></td></tr></table></figure>

<p>配置webpack</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">const isDev &#x3D; process.env.NODE_ENV &#x3D;&#x3D;&#x3D; &#39;development&#39; &#x2F;&#x2F; 获取环境变量</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F; const config &#x3D; ... 看上面的配置</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F; 如果是开发环境则添加服务器配置</span><br><span class="line">if (isDev) &#123;</span><br><span class="line">    &#x2F;&#x2F; 不直接使用编译后的代码，而是展示源码映射，方便调试</span><br><span class="line">    config.devTool &#x3D; &#39;#cheap-module-eval-source-map&#39;</span><br><span class="line">    config.devServer &#x3D; &#123;</span><br><span class="line">            port: 8001,</span><br><span class="line">            host: &#39;0.0.0.0&#39;, &#x2F;&#x2F; 本机ip和127.0.0.1都可以访问</span><br><span class="line">            overlay: &#123;</span><br><span class="line">                errors: true &#x2F;&#x2F; 遇到错误都打印出来</span><br><span class="line">            &#125;,</span><br><span class="line">            &#x2F;&#x2F; 开启热更新</span><br><span class="line">            hot: true</span><br><span class="line">        &#125;</span><br><span class="line">        &#x2F;&#x2F; 添加热更新插件</span><br><span class="line">    config.plugins.push(</span><br><span class="line">        new webpack.HotModuleReplacementPlugin()</span><br><span class="line">    )</span><br><span class="line">    config.plugins.push(</span><br><span class="line">        new webpack.NoEmitOnErrorsPlugin()</span><br><span class="line">    )</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ol start="4">
<li><p>额外的必须配置，babel、postcss</p>
<p>安装</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">npm i autoprefixer postcss-loader babel-core babel-loader &#x2F;&#x2F; postcss、babel依赖</span><br><span class="line">npm i babel-preset-env babel-plugin-transform-vue-jsx &#x2F;&#x2F; babel依赖</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>配置css后处理器,postcss.config.js</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">const autoprefixer &#x3D; require(&#39;autoprefixer&#39;)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F; 自动优化处理css，比如各种浏览器的特性web-kit这种</span><br><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">    plugins: [</span><br><span class="line">        autoprefixer()</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>.babelrc</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    &quot;presets&quot;: [</span><br><span class="line">        &quot;env&quot;</span><br><span class="line">    ],</span><br><span class="line">    &quot;plugins&quot;: [</span><br><span class="line">        &quot;transform-vue-jsx&quot;</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ol>
</li>
</ol>
<h3 id="二、-vue2"><a href="#二、-vue2" class="headerlink" title="二、 vue2"></a>二、 vue2</h3><ol>
<li><p>特点</p>
<p>数据绑定</p>
<p>vue文件</p>
<p>render方法(当组件变化重新执行render方法)</p>
<p>生命周期方法</p>
<p>computed(由于vue基于reactive，视图基于数据改变)</p>
</li>
<li><p>注意点</p>
<ul>
<li>数据在哪定义就在哪操作</li>
</ul>
</li>
</ol>
<h3 id="三、-css"><a href="#三、-css" class="headerlink" title="三、 css"></a>三、 css</h3><p>居中并铺满父元素:</p>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">position</span> absolute</span><br><span class="line">       <span class="attribute">top</span> <span class="number">0</span></span><br><span class="line">       <span class="attribute">bottom</span> <span class="number">0</span></span><br><span class="line">       <span class="attribute">left</span> <span class="number">0</span></span><br><span class="line">       <span class="attribute">right</span> <span class="number">0</span></span><br></pre></td></tr></table></figure>



<h3 id="四、-webpack打包优化"><a href="#四、-webpack打包优化" class="headerlink" title="四、 webpack打包优化"></a>四、 webpack打包优化</h3><p>将资源分离，便于缓存，如js、css文件，浏览器会进行缓存，减少带宽，生产环境的配置如下</p>
<figure class="highlight cmd"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm i extract-text-webpack-plugin -D</span><br></pre></td></tr></table></figure>



<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> ExtractPlugin = <span class="built_in">require</span>(<span class="string">&#x27;extract-text-webpack-plugin&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 生产模式使用chunkhash</span></span><br><span class="line">   config.output.filename = <span class="string">&#x27;[name].[chunkhash:8].js&#x27;</span></span><br><span class="line">   <span class="comment">// 生产模式下用ExtractPlugin</span></span><br><span class="line">   config.module.rules.push(&#123;</span><br><span class="line">       test: <span class="regexp">/\.styl/</span>,</span><br><span class="line">       use: ExtractPlugin.extract(&#123;</span><br><span class="line">           <span class="comment">// style-loader会将css打包到js中，我们要分离，所以要这样子</span></span><br><span class="line">           fallback: <span class="string">&#x27;style-loader&#x27;</span>,</span><br><span class="line">           use: [</span><br><span class="line">               <span class="string">&#x27;css-loader&#x27;</span>,</span><br><span class="line">               <span class="comment">// 为stylus加上postcss处理器，同时当其他loader生成sourceMap后复用而不重新创建</span></span><br><span class="line">               &#123;</span><br><span class="line">                   loader: <span class="string">&#x27;postcss-loader&#x27;</span>,</span><br><span class="line">                   options: &#123;</span><br><span class="line">                       sourceMap: <span class="literal">true</span></span><br><span class="line">                   &#125;</span><br><span class="line">               &#125;,</span><br><span class="line">               <span class="string">&#x27;stylus-loader&#x27;</span></span><br><span class="line">           ]</span><br><span class="line">       &#125;)</span><br><span class="line">   &#125;)</span><br><span class="line">   config.plugins.push(</span><br><span class="line">       <span class="keyword">new</span> ExtractPlugin(<span class="string">&#x27;styles.[contentHash:8].css&#x27;</span>)</span><br><span class="line">   )</span><br></pre></td></tr></table></figure>

<p>由于框架的js代码比较稳定，故将代码单独分离打包，以便浏览器缓存</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 生产模式下，将框架的js代码单独出来，方便浏览器缓存</span></span><br><span class="line">   config.entry = &#123;</span><br><span class="line">       app: path.join(__dirname, <span class="string">&#x27;src/main.js&#x27;</span>),</span><br><span class="line">       vendor: [<span class="string">&#x27;vue&#x27;</span>]</span><br><span class="line">   &#125;</span><br><span class="line"></span><br><span class="line">   config.optimization = &#123;</span><br><span class="line">       splitChunks: &#123;</span><br><span class="line">           cacheGroups: &#123;</span><br><span class="line">               commons: &#123;</span><br><span class="line">                   name: <span class="string">&quot;vendor&quot;</span></span><br><span class="line">               &#125;</span><br><span class="line">           &#125;</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>

<p>将webpack的代码独立打包</p>
<p>视频中的方法是错的，不适用与webpack4</p>
<p>使用这个loader报错:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#123; &#x2F;&#x2F; 将js语法从es6转换为浏览器兼容类型</span><br><span class="line">              test: &#x2F;\.js$&#x2F;,</span><br><span class="line">              loader: &#39;babel-loader&#39;,</span><br><span class="line">              &#x2F;&#x2F; node_modules已经编译过了不用重新编译</span><br><span class="line">              exclude: &#x2F;node_modules&#x2F;</span><br><span class="line">          &#125;,</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">ERROR in .&#x2F;src&#x2F;main.js</span><br><span class="line">Module build failed (from .&#x2F;node_modules&#x2F;babel-loader&#x2F;lib&#x2F;index.js):</span><br><span class="line">TypeError: Cannot read property &#39;bindings&#39; of null</span><br><span class="line">    at Scope.moveBindingTo (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\scope\index.js:830:13)</span><br><span class="line">    at BlockScoping.updateScopeInfo (E:\javaweb\webstrom\todo\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:364:17)</span><br><span class="line">    at BlockScoping.run (E:\javaweb\webstrom\todo\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:330:12)</span><br><span class="line">    at PluginPass.BlockStatementSwitchStatementProgram (E:\javaweb\webstrom\todo\node_modules\babel-plugin-transform-es2015-block-scoping\lib\index.js:70:24)</span><br><span class="line">    at newFn (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\visitors.js:179:21)</span><br><span class="line">    at NodePath._call (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\path\context.js:55:20)</span><br><span class="line">    at NodePath.call (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\path\context.js:42:17)</span><br><span class="line">    at NodePath.visit (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\path\context.js:90:31)</span><br><span class="line">    at TraversalContext.visitQueue (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\context.js:112:16)</span><br><span class="line">    at TraversalContext.visitSingle (E:\javaweb\webstrom\todo\node_modules\@babel\traverse\lib\context.js:84:19)</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/Joe-and-Joan/p/10335881.html">解决办法</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E5%89%8D%E7%AB%AF/vue%20+%20webpack%E7%AE%80%E5%8D%95%E5%AD%A6%E4%B9%A0/" data-id="ckdkdagu4000avout41sg36x0" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-理论/设计模式学习(UML的学习)" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E7%90%86%E8%AE%BA/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E5%AD%A6%E4%B9%A0(UML%E7%9A%84%E5%AD%A6%E4%B9%A0)/" class="article-date">
  <time datetime="2020-08-07T15:08:02.617Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="设计模式学习-UML的学习"><a href="#设计模式学习-UML的学习" class="headerlink" title="设计模式学习(UML的学习)"></a>设计模式学习(UML的学习)</h2><h3 id="零、UML"><a href="#零、UML" class="headerlink" title="零、UML"></a>零、UML</h3><h4 id="1-是什么"><a href="#1-是什么" class="headerlink" title="1. 是什么"></a>1. 是什么</h4><p>​    系统可视化的一种方法</p>
<h4 id="2-分类"><a href="#2-分类" class="headerlink" title="2. 分类"></a>2. 分类</h4><ol>
<li><p>结构式图形:强调的是系统式建模</p>
<p>包含静态图(类图、对象图、包图)、实现图(组件图、部署图)、剖面图、复合结构图</p>
</li>
<li><p>行为式图形:强调系统模型中触发的事件</p>
<p>活动图、状态图、用例图</p>
</li>
<li><p>交互式图形:属于行为式图形的子集，强调系统模型中的流程</p>
<p>通信图、交互概述图、时序图、时间图</p>
</li>
</ol>
<h3 id="一、类图"><a href="#一、类图" class="headerlink" title="一、类图"></a>一、类图</h3><p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200118150620135.png" alt="image-20200118150620135"></p>
<h4 id="1-类的基本表示"><a href="#1-类的基本表示" class="headerlink" title="1.类的基本表示"></a>1.类的基本表示</h4><p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200118151023947.png" alt="image-20200118151023947"></p>
<h5 id="权限符号"><a href="#权限符号" class="headerlink" title="权限符号:"></a>权限符号:</h5><ul>
<li>public +</li>
<li>private -</li>
<li>protected #</li>
<li>默认 ~</li>
</ul>
<h5 id="注意点"><a href="#注意点" class="headerlink" title="注意点:"></a>注意点:</h5><ul>
<li>抽象方法使用斜体</li>
<li>静态方法使用下划线</li>
</ul>
<h4 id="2-类之间的关系"><a href="#2-类之间的关系" class="headerlink" title="2.类之间的关系"></a>2.类之间的关系</h4><p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200118151309286.png" alt="image-20200118151309286"></p>
<p>其中：</p>
<pre><code>1. 依赖关系：虚线箭头，类需要使用其他的类做参数或返回
 2. 泛化关系（is a）：表示继承关系，空心三角箭头从子类指向父类</code></pre>
<ol start="3">
<li><p>组合关系：黑色菱形和箭头，表示两个类有相同的生命周期，同时菱形一头在主类上，左右可以写数字，表示几个主类包含多少个副类</p>
</li>
<li><p>关联关系: 用实线箭头表示，一般表示一个类与另一个类相关联，一般为一个类作为另一个类的属性</p>
</li>
<li><p>聚合关系：用空心菱形和箭头表示，表示菱形一边的类由多个箭头一边的类聚合而成</p>
</li>
<li><p>实现：空心三角和虚线，空心三角指向接口，棒棒糖表示法中用圆圈表示接口</p>
</li>
</ol>
<h3 id="二、时序图-顺序图"><a href="#二、时序图-顺序图" class="headerlink" title="二、时序图(顺序图)"></a>二、时序图(顺序图)</h3><h4 id="1-是什么-1"><a href="#1-是什么-1" class="headerlink" title="1. 是什么"></a>1. 是什么</h4><p>​    是显示对象之间交互的图，这些对象是按时间顺序排列的</p>
<h4 id="2-主要元素"><a href="#2-主要元素" class="headerlink" title="2. 主要元素"></a>2. 主要元素</h4><p>​    对象、生命线、控制焦点、消息等</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200118155729907.png" alt="image-20200118155729907"></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E7%90%86%E8%AE%BA/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E5%AD%A6%E4%B9%A0(UML%E7%9A%84%E5%AD%A6%E4%B9%A0)/" data-id="ckdkdagw1000zvout458c4e65" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-理论/UML" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E7%90%86%E8%AE%BA/UML/" class="article-date">
  <time datetime="2020-08-07T15:08:02.285Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="UML-不要画的过细，不然不如写代码"><a href="#UML-不要画的过细，不然不如写代码" class="headerlink" title="UML(不要画的过细，不然不如写代码)"></a>UML(不要画的过细，不然不如写代码)</h2><h3 id="0-注意点"><a href="#0-注意点" class="headerlink" title="0. 注意点"></a>0. 注意点</h3><p>​    不是为了画图而画图，是为了让人读懂我的系统，理解我的软件</p>
<h3 id="1-什么是uml"><a href="#1-什么是uml" class="headerlink" title="1. 什么是uml"></a>1. 什么是uml</h3><p>是一种图形表示法，用于问题的分析</p>
<p><strong>表示法、工具(rose)、过程</strong>软件建模三大要素</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200119114844646.png" alt="image-20200119114844646"></p>
<h3 id="2-分析"><a href="#2-分析" class="headerlink" title="2. 分析"></a>2. 分析</h3><p>问题：</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200119115215044.png" alt="image-20200119115215044"></p>
<p>过程: 定义用例 –&gt; 定义领域模型 –&gt; 定义交互图 –&gt; 定义设计类图</p>
<ol>
<li><p>定义用例(有什么功能，我想要干什么):</p>
<pre><code>1. 游戏者请求骰子
 2. 展示游戏结果，为7点赢，否则输</code></pre>
</li>
<li><p>定义领域模型(识别问题中的概念，对真实世界领域中的概念或想象的可视化)</p>
<ol>
<li>游戏者</li>
<li>骰子游戏</li>
<li>骰子</li>
</ol>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200119120038908.png" alt="image-20200119120038908"></p>
</li>
<li><p>交互图(职责与协作)</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200119120257477.png" alt="image-20200119120257477"></p>
</li>
<li><p>设计(从领域模型和交互图中获取一些启示，定义软件类，包括属性、方法等)</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200119120619130.png" alt="image-20200119120619130"></p>
</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E7%90%86%E8%AE%BA/UML/" data-id="ckdkdagw0000yvout2inhckt6" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-理论/HTTP" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E7%90%86%E8%AE%BA/HTTP/" class="article-date">
  <time datetime="2020-08-07T15:08:02.188Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="HTTP"><a href="#HTTP" class="headerlink" title="HTTP"></a>HTTP</h2><p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200127132617588.png" alt="image-20200127132617588"></p>
<h3 id="一、HTTP各版本特性"><a href="#一、HTTP各版本特性" class="headerlink" title="一、HTTP各版本特性"></a>一、HTTP各版本特性</h3><ol>
<li>HTTP/0.9</li>
</ol>
<p>只有GET方法</p>
<p>没有Header等描述数据的信息</p>
<p>服务发送完毕即关闭TCP连接</p>
<ol start="2">
<li>HTTP/1.0</li>
</ol>
<p>增加了很多命令</p>
<p>增加了status Code和headers</p>
<p>多字符支持，多部分发送，权限，缓存等</p>
<ol start="3">
<li>HTTP/1.1</li>
</ol>
<p>持久连接</p>
<p>pipeline(客户端的请求可以在同一个连接中发送，但是服务端需要顺序的返回响应，导致即使后一个请求处理完成了也要等待前一个请求处理并返回)</p>
<p>增加了host和其他一些命令(可以在同一台物理服务器中跑多台网络服务器)</p>
<ol start="3">
<li>HTTP/2</li>
</ol>
<p>所有数据以二进制传输</p>
<p>同一个连接可以发送多个请求且不需要按顺序响应</p>
<p>头信息压缩以及推送等提高效率的功能</p>
<h3 id="二、URI、URL、URN"><a href="#二、URI、URL、URN" class="headerlink" title="二、URI、URL、URN"></a>二、URI、URL、URN</h3><ol>
<li>URI(uniform Resource Identifier)</li>
</ol>
<p>统一资源标志符</p>
<ol start="2">
<li>URL(uniform Resource Locator)</li>
</ol>
<p>统一资源定位符</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200127142348017.png" alt="image-20200127142348017"></p>
<ol start="3">
<li>URN</li>
</ol>
<p>永久统一资源定位符</p>
<p>在资源移动后还能找到</p>
<p>目前没有成熟的使用方案</p>
<h3 id="三、HTTP报文"><a href="#三、HTTP报文" class="headerlink" title="三、HTTP报文"></a>三、HTTP报文</h3><p><strong>注意</strong>:method需要大写，header忽略大小写</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200127143618063.png" alt="image-20200127143618063"></p>
<p>头部和主体用空行分隔</p>
<ol>
<li><p>跨域请求</p>
<p>Access-Control-Allow-Origin: * //允许请求源</p>
<p>Access-Control-Allow-Headers: X-Test-Cors //允许请求头</p>
<p>Access-Control-Allow-Methods: PUT //允许请求方法</p>
<p>Access-Control-Allow-Max-Age: 1000 // 发送预请求后的验证的时间</p>
<p>表示允许所有地址跨域</p>
<p>如果不设置请求会发送，内容也返回了，但浏览器会拦截，但浏览器允许img、script等标签跨域，不会进行拦截</p>
<p>注意:</p>
<ul>
<li><p>默认允许method为GET、POST、HEAD</p>
</li>
<li><p>默认允许content-type为text/plain、multipart/form-data、application/x-www-form-urlencoded</p>
</li>
<li><p>请求头:自定义的请求头不允许,还有一些需要查看文档</p>
</li>
</ul>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200127170750323.png" alt="image-20200127170750323"></p>
<p>预请求:使用options方法，获得服务器端允许的认可</p>
</li>
</ol>
<ol start="2">
<li><p>缓存 </p>
<p>Cache-Control</p>
</li>
</ol>
<ul>
<li><p>public </p>
<p>http请求经过的任何一个地方可以缓存</p>
</li>
<li><p>private </p>
<p>只有发起请求的浏览器可以缓存</p>
</li>
<li><p>no-cache</p>
<p>每次都需要服务器验证缓存是否有效</p>
</li>
</ul>
<p>  max-age=多少秒  // 缓存有效时间</p>
<p>  s-maxage=多少秒 // 为代理服务器准备的头，可以覆盖max-age</p>
<p>  max-stale=多少秒 //发起请求方在一定时间仍使用过期请求</p>
<p>  must-revalidate //过期不能直接使用缓存，需要去访问源服务器校验是否过期</p>
<p>  proxy-revalidate //指定缓存服务器在过期时需要重新验证</p>
<p>  no-store //永远都不能使用缓存</p>
<p>  no-transform // 告知代理服务器不能改动内容</p>
<p>  Last-Modified</p>
<p>  上次修改时间</p>
<p>  配合If-Modified-Since或If-Unmodified-Since使用</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">graph TB</span><br><span class="line">客户端获取本地缓存的last-modified时间 --&gt; 服务器比较请求的静态资源的上次修改时间 --&gt; 返回响应是否使用缓存</span><br></pre></td></tr></table></figure>

<p>  Etag</p>
<p>  数据签名</p>
<p>  配合If-Match或If-Non-Match</p>
<p>  对比资源的签名是否使用缓存</p>
<p>实验结果:</p>
<ol>
<li>如果资源只有Cache-Control: max-age=时长,则直接根据缓存时间来决定是否使用缓存</li>
<li>如果使用了Cache-Control: max-age=时长,no-cache,那么每次请求都会到服务器，并携带If-Modified-Since和If-None-Match等header去校验有无缓存，若有则为304</li>
<li>如果使用了Cache-Control: max-age=时长,no-store,那么将会忽略缓存相关的header</li>
</ol>
<h3 id="四、nginx"><a href="#四、nginx" class="headerlink" title="四、nginx"></a>四、nginx</h3><p><a target="_blank" rel="noopener" href="https://my.oschina.net/u/2366984/blog/1918742">相关连接</a></p>
<h4 id="常用命令"><a href="#常用命令" class="headerlink" title="常用命令:"></a>常用命令:</h4><ol>
<li>查看版本号</li>
</ol>
<p>./nginx -v</p>
<ol start="2">
<li>启动</li>
</ol>
<p>./nginx</p>
<ol start="3">
<li>关闭</li>
</ol>
<p>./nginx -s stop</p>
<ol start="4">
<li>重加载</li>
</ol>
<p>./nginx -s reload</p>
<h4 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h4><ol>
<li><p>全局块</p>
<p>影响nginx服务器整体运行的配置</p>
<p>work_processors 值越大并发处理并发越好</p>
</li>
<li><p>event块</p>
<p>影响NGINX服务器和用户网络的连接</p>
</li>
<li><p>http块</p>
<p>配置代理、缓存等</p>
<p>包含server块</p>
</li>
</ol>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/LiuQizhong/p/11757420.html">相关文章</a></p>
<h4 id="缓存"><a href="#缓存" class="headerlink" title="缓存"></a>缓存</h4><p>proxy_cache_path cache  // 配置缓存路径</p>
<p>levels=1:2 分子文件夹</p>
<p>keys_zone=缓存名:内存大小</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">proxy_cache_path cache levels&#x3D;1:2 keys_zone&#x3D;mycache:10m</span><br></pre></td></tr></table></figure>

<p>s-max-age可以让代理服务器指定缓存时间</p>
<p>Vary指定相应的头信息一样才使用缓存</p>
<h3 id="五、HTTPS-安全的HTTP"><a href="#五、HTTPS-安全的HTTP" class="headerlink" title="五、HTTPS(安全的HTTP)"></a>五、HTTPS(安全的HTTP)</h3><h4 id="加密"><a href="#加密" class="headerlink" title="加密"></a>加密</h4><ol>
<li><p>公钥</p>
<p>互联网上谁都可以拿到用来加密的秘钥</p>
</li>
<li><p>私钥</p>
<p>在服务器上，不会进行传输，用于解密公钥加密的数据</p>
</li>
</ol>
<h3 id="六、HTTP2"><a href="#六、HTTP2" class="headerlink" title="六、HTTP2"></a>六、HTTP2</h3><p>对比HTTP/1.1优势</p>
<ol>
<li>信道复用</li>
<li>分桢传输</li>
<li>Server Push</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E7%90%86%E8%AE%BA/HTTP/" data-id="ckdkdagvz000xvoutfy766sgh" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-考研/考研数学概述" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E8%80%83%E7%A0%94/%E8%80%83%E7%A0%94%E6%95%B0%E5%AD%A6%E6%A6%82%E8%BF%B0/" class="article-date">
  <time datetime="2020-08-07T15:08:02.171Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h3><h4 id="1-卷面分值"><a href="#1-卷面分值" class="headerlink" title="1. 卷面分值"></a>1. 卷面分值</h4><ul>
<li>选择题 8 x 4 = 32 有一部分难题 </li>
<li>填空题 6 x 4 = 24 基础知识的考察</li>
<li>大题 (94)<ul>
<li>5 x 10 </li>
<li>4 x 11</li>
</ul>
</li>
</ul>
<h4 id="2-试卷分类"><a href="#2-试卷分类" class="headerlink" title="2. 试卷分类"></a>2. 试卷分类</h4><ul>
<li><p>数二</p>
<p>高数 116</p>
<p>线代 34</p>
</li>
</ul>
<h4 id="3-范围"><a href="#3-范围" class="headerlink" title="3. 范围"></a>3. 范围</h4><ul>
<li><p>高数</p>
<ol>
<li><p>极限与连续 ✔</p>
</li>
<li><p>导数与微分</p>
<p>中值定理与一元微分应用 ✔</p>
</li>
<li><p>不定积分理论</p>
<p>定积分理论 ✔</p>
<p>定积分应用 ✔</p>
</li>
<li><p>微分方程 ✔</p>
</li>
<li><p>多元微分学 （一、二、三）</p>
</li>
<li><p>二重积分（一、二、三）</p>
</li>
<li><p>极数（一、三）</p>
</li>
<li><p>空间解析几何</p>
<p>曲线与曲面积分 ✔</p>
<p>三重积分</p>
</li>
</ol>
</li>
<li><p>线性代数</p>
<ul>
<li><p>线性方程组</p>
<p>工具: 行列式，向量组，矩阵</p>
</li>
<li><p>矩阵对角化 ✔ 一定有一个大题</p>
<p>工具：特征值与特征向量</p>
</li>
</ul>
</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E8%80%83%E7%A0%94/%E8%80%83%E7%A0%94%E6%95%B0%E5%AD%A6%E6%A6%82%E8%BF%B0/" data-id="ckdkdagw70012vout4is86u8m" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-考研/SpringBoot的学习" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E8%80%83%E7%A0%94/SpringBoot%E7%9A%84%E5%AD%A6%E4%B9%A0/" class="article-date">
  <time datetime="2020-08-07T15:08:02.166Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="SpringBoot的学习"><a href="#SpringBoot的学习" class="headerlink" title="SpringBoot的学习"></a>SpringBoot的学习</h2><h3 id="1-跨域请求"><a href="#1-跨域请求" class="headerlink" title="1. 跨域请求"></a>1. 跨域请求</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">@Configuration</span><br><span class="line">public class MvcConfig implements WebMvcConfigurer &#123;</span><br><span class="line"></span><br><span class="line">    &#x2F;**</span><br><span class="line">     * 添加跨域</span><br><span class="line">     *&#x2F;</span><br><span class="line">    @Override</span><br><span class="line">    public void addCorsMappings(CorsRegistry registry) &#123;</span><br><span class="line">        registry.addMapping(&quot;&#x2F;*&quot;)</span><br><span class="line">                .allowCredentials(true)</span><br><span class="line">                .allowedHeaders(&quot;*&quot;)</span><br><span class="line">                .allowedMethods(&quot;*&quot;)</span><br><span class="line">                .allowedOrigins(&quot;*&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="2-配置FastJson"><a href="#2-配置FastJson" class="headerlink" title="2. 配置FastJson"></a>2. 配置FastJson</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;**</span><br><span class="line">  * 配置fastJson策略</span><br><span class="line">  *&#x2F;</span><br><span class="line"> @Override</span><br><span class="line"> public void configureMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) &#123;</span><br><span class="line">     FastJsonHttpMessageConverter converter &#x3D; new FastJsonHttpMessageConverter();</span><br><span class="line">     FastJsonConfig config &#x3D; new FastJsonConfig();</span><br><span class="line">     config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect,</span><br><span class="line">             SerializerFeature.WriteMapNullValue);</span><br><span class="line">     converter.setFastJsonConfig(config);</span><br><span class="line">     converters.add(converter);</span><br><span class="line"> &#125;</span><br></pre></td></tr></table></figure>

<h3 id="3-可以将网站的访问记录放入数据库中，通过SpringMvc拦截器实现"><a href="#3-可以将网站的访问记录放入数据库中，通过SpringMvc拦截器实现" class="headerlink" title="3. 可以将网站的访问记录放入数据库中，通过SpringMvc拦截器实现"></a>3. 可以将网站的访问记录放入数据库中，通过SpringMvc拦截器实现</h3><h3 id="4-添加或重定向静态资源的访问路径，配置前的原路径仍可访问"><a href="#4-添加或重定向静态资源的访问路径，配置前的原路径仍可访问" class="headerlink" title="4. 添加或重定向静态资源的访问路径，配置前的原路径仍可访问"></a>4. 添加或重定向静态资源的访问路径，配置前的原路径仍可访问</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@Override</span><br><span class="line">public void addResourceHandlers(ResourceHandlerRegistry registry) &#123;</span><br><span class="line">    registry.addResourceHandler(&quot;&#x2F;good&#x2F;**&quot;).addResourceLocations(&quot;classpath:&#x2F;static&#x2F;&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="5-Servlet的自动装配"><a href="#5-Servlet的自动装配" class="headerlink" title="5. Servlet的自动装配"></a>5. Servlet的自动装配</h3><ol>
<li><p>方法一</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@Bean</span><br><span class="line">public ServletRegistrationBean test () &#123;</span><br><span class="line">    return new ServletRegistrationBean(new TestServlet(),&quot;&#x2F;test&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ol>
<ol start="2">
<li><p>方法二</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">@Configuration</span><br><span class="line">@ServletComponentScan(&quot;com.originit&quot;)</span><br><span class="line">public Class ServletConfig &#123;&#125;</span><br><span class="line"></span><br><span class="line">@WebServlet(urlPatterns &#x3D; &quot;&#x2F;test&quot;)</span><br><span class="line">public class TestServlet extends HttpServlet &#123;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException &#123;</span><br><span class="line">        resp.getWriter().println(&quot;ca&quot;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ol>
<h3 id="6-文件上传"><a href="#6-文件上传" class="headerlink" title="6. 文件上传"></a>6. 文件上传</h3><p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200211163259119.png" alt="image-20200211163259119"></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E8%80%83%E7%A0%94/SpringBoot%E7%9A%84%E5%AD%A6%E4%B9%A0/" data-id="ckdkdagw40011vout1usugt44" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-考研/Maven打包部署SpringBoot项目" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E8%80%83%E7%A0%94/Maven%E6%89%93%E5%8C%85%E9%83%A8%E7%BD%B2SpringBoot%E9%A1%B9%E7%9B%AE/" class="article-date">
  <time datetime="2020-08-07T15:08:02.159Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Maven打包部署SpringBoot项目"><a href="#Maven打包部署SpringBoot项目" class="headerlink" title="Maven打包部署SpringBoot项目"></a>Maven打包部署SpringBoot项目</h3><h3 id="0-前言"><a href="#0-前言" class="headerlink" title="0. 前言"></a>0. 前言</h3><p>maven的install实际的意义是将模块放入本地的maven仓库，如果不install的话，那么maven将找不到他依赖的模块，而且当模块代码或依赖更新后，也需要重新install，如果使用mapStruct，则要求所有的组员都都将各个模块install到电脑，可以按照以下步骤完成,由mapStruce让我认识到稍微大一点的项目中不要使用这种框架，因为一旦有一个人没有配置环境就无法运行</p>
<h3 id="1-如果项目的子模块依赖于父项目"><a href="#1-如果项目的子模块依赖于父项目" class="headerlink" title="1. 如果项目的子模块依赖于父项目"></a>1. 如果项目的子模块依赖于父项目</h3><p>先将父项目的modules标签注释掉，刷新配置，然后install父项目</p>
<h3 id="2-install各个子模块"><a href="#2-install各个子模块" class="headerlink" title="2. install各个子模块"></a>2. install各个子模块</h3><p>从最底层的子模块开始install，如果出现：Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project service: There are test failures</p>
<p>则添加插件,跳过单元测试:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">          <span class="comment">&lt;!--执行测试用例的插件--&gt;</span></span><br><span class="line">          <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-surefire-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                  <span class="comment">&lt;!--跳过项目运行测试用例--&gt;</span></span><br><span class="line">                  <span class="tag">&lt;<span class="name">skipTests</span>&gt;</span>true<span class="tag">&lt;/<span class="name">skipTests</span>&gt;</span></span><br><span class="line">              <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">          <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="3-package顶层的可运行模块"><a href="#3-package顶层的可运行模块" class="headerlink" title="3. package顶层的可运行模块"></a>3. package顶层的可运行模块</h3><p>简介:将模块以及他的子模块打包成一个可运行的产物，如war、jar文件</p>
<p>此过程中可能会遇到一些问题，如java -jar启动时主类找不到，我们需要在pom.xml添加如下插件:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="comment">&lt;!-- 如果项目依赖jar文件，则需要添加此配置 --&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">includeSystemScope</span>&gt;</span>true<span class="tag">&lt;/<span class="name">includeSystemScope</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>依赖的各jar包要用dependency配置:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">       <span class="tag">&lt;<span class="name">groupId</span>&gt;</span> com.xxc <span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">       <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span> logger <span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">       <span class="tag">&lt;<span class="name">version</span>&gt;</span>0.0.1-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">       <span class="tag">&lt;<span class="name">scope</span>&gt;</span>system<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">       <span class="tag">&lt;<span class="name">systemPath</span>&gt;</span>$&#123;basedir&#125;/lib/logger.jar<span class="tag">&lt;/<span class="name">systemPath</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>添加如下配置可以将资源文件进行打包:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">         <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">             <span class="tag">&lt;<span class="name">directory</span>&gt;</span>src/main/java/resources<span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">             <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                 <span class="comment">&lt;!--包含文件夹以及子文件夹下所有资源--&gt;</span></span><br><span class="line">                 <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*.*<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">             <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">         <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">     <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E8%80%83%E7%A0%94/Maven%E6%89%93%E5%8C%85%E9%83%A8%E7%BD%B2SpringBoot%E9%A1%B9%E7%9B%AE/" data-id="ckdkdagw30010voutfatb9nee" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  
    <article id="post-开发笔记/开发笔记 2025" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="./2020/08/07/%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0/%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0%202025/" class="article-date">
  <time datetime="2020-08-07T15:08:02.130Z" itemprop="datePublished">2020-08-07</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="Vue学习中常用知识"><a href="#Vue学习中常用知识" class="headerlink" title="Vue学习中常用知识"></a>Vue学习中常用知识</h4><h4 id="1-左右布局"><a href="#1-左右布局" class="headerlink" title="1. 左右布局"></a>1. 左右布局</h4><p>一般的<strong>左右布局(左边固定，右边占满剩余)**都是依赖于</strong>脱离文档流<strong>和</strong>div宽度会占满父元素**两个特性来实现的，只要左边的元素脱离文档流，则他就会浮在右边元素上，只要让右边元素的内容区刚好与左边元素相贴即可</p>
<p>如浮动实现，浮动使得左边的元素脱离文档流，然后给右边的div添加一个左边距，如此即可</p>
<figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">@leftWidth:</span> <span class="number">200px</span>;</span><br><span class="line">  <span class="selector-class">.content</span> &#123;</span><br><span class="line">    <span class="selector-tag">&amp;</span>&gt;<span class="selector-class">.left</span> &#123;</span><br><span class="line">      <span class="attribute">float</span>: left;</span><br><span class="line">      <span class="attribute">width</span>: <span class="variable">@leftWidth</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="selector-tag">&amp;</span>&gt;<span class="selector-class">.right</span> &#123;</span><br><span class="line">      <span class="attribute">margin-left</span>: <span class="variable">@leftWidth</span>;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>而绝对定位的实现呢，只是将浮动改为绝对定位即可</p>
<h4 id="2-不熟悉的标签不要乱用"><a href="#2-不熟悉的标签不要乱用" class="headerlink" title="2.不熟悉的标签不要乱用"></a>2.不熟悉的标签不要乱用</h4><p>在开发中，使用el-row、el-col作为vue组件的根元素，出现了如页面被el-row撑开，el-pagination永远在上一行等等奇怪的问题</p>
<h4 id="3-div就是铺满父元素的"><a href="#3-div就是铺满父元素的" class="headerlink" title="3. div就是铺满父元素的"></a>3. div就是铺满父元素的</h4><p>一直以来想着用<code>width:100%</code>来铺满父元素，但是这样会出现巨大的问题，会让子元素超出父元素的内容区，如<strong>第1点</strong>实现的左右布局若使用padding-left代替margin-left，则子元素与父元素的关系如图所示:</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200205230500224.png" alt="image-20200205230500224"></p>
<h4 id="4-SessionStroage是窗口内有效"><a href="#4-SessionStroage是窗口内有效" class="headerlink" title="4. SessionStroage是窗口内有效"></a>4. SessionStroage是窗口内有效</h4><h4 id="5-Promise的finally、done方法无效"><a href="#5-Promise的finally、done方法无效" class="headerlink" title="5. Promise的finally、done方法无效"></a>5. Promise的finally、done方法无效</h4><p>原生的Promise是没有这两个方法的，可以使用npm install axios promise.prototype.finally –save   然后require(‘promise.prototype.finally’).shim()<br>参考<a target="_blank" rel="noopener" href="https://github.com/axios/axios/issues/457">https://github.com/axios/axio…</a></p>
<h4 id="6-provide、inject"><a href="#6-provide、inject" class="headerlink" title="6. provide、inject"></a>6. provide、inject</h4><p>使用provide和inject机制可以使得父组件的数据传递到后代组件中，而无需一级一级传递，但是，他们管理的数据不是响应式的，我们可以使用vuex做到同样的功能，而且数据是响应式的</p>
<h4 id="7-webstorm对路径别名无提示，如"><a href="#7-webstorm对路径别名无提示，如" class="headerlink" title="7. webstorm对路径别名无提示，如@"></a>7. webstorm对路径别名无提示，如@</h4><p>在项目的根目录创建一个alias.config.js文件，如下所述</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;**</span><br><span class="line"> * 由于 Vue CLI 3 不再使用传统的 webpack 配置文件，故 WebStorm 无法识别别名</span><br><span class="line"> * 本文件对项目无任何作用，仅作为 WebStorm 识别别名用</span><br><span class="line"> * 进入 WebStorm preferences -&gt; Language &amp; Framework -&gt; JavaScript -&gt; Webpack，选择这个文件即可</span><br><span class="line"> * *&#x2F;</span><br><span class="line">const resolve &#x3D; dir &#x3D;&gt; require(&#39;path&#39;).join(__dirname, dir);</span><br><span class="line"></span><br><span class="line">module.exports &#x3D; &#123;</span><br><span class="line">  resolve: &#123;</span><br><span class="line">    alias: &#123;</span><br><span class="line">      &#39;@&#39;: resolve(&#39;src&#39;)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h4 id="8-jest出现问题-Test-suite-failed-to-run-SecurityError-localStorage-is-not-available-for-opaque-origins"><a href="#8-jest出现问题-Test-suite-failed-to-run-SecurityError-localStorage-is-not-available-for-opaque-origins" class="headerlink" title="8. jest出现问题:  Test suite failed to run SecurityError: localStorage is not available for opaque origins"></a>8. jest出现问题:  Test suite failed to run SecurityError: localStorage is not available for opaque origins</h4><p>配置一下两项</p>
<p><img src="C:\Users\xxc、\AppData\Roaming\Typora\typora-user-images\image-20200211131622880.png" alt="image-20200211131622880"></p>
<p>在jest.config.js中添加配置项：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">verbose: true,</span><br><span class="line">testURL: &#39;http:&#x2F;&#x2F;localhost&#x2F;&#39;</span><br></pre></td></tr></table></figure>

<h4 id="9-git-clone-出现问题：fatal-protocol-‘https’-is-not-supported"><a href="#9-git-clone-出现问题：fatal-protocol-‘https’-is-not-supported" class="headerlink" title="9.git clone 出现问题：fatal: protocol ‘https’ is not supported"></a>9.git clone 出现问题：fatal: protocol ‘https’ is not supported</h4><p>git bash中shift + ins才是粘贴，我们ctrl + v输入了一个隐藏字符</p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/baidu_41704597/article/details/99718232">原文参考</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/08/07/%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0/%E5%BC%80%E5%8F%91%E7%AC%94%E8%AE%B0%202025/" data-id="ckdkdagvo000rvout2i72axny" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="./">&amp;laquo; Prev</a><a class="page-number" href="./">1</a><span class="page-number current">2</span><a class="page-number" href="./page/3/">3</a><a class="page-number" href="./page/4/">4</a><a class="extend next" rel="next" href="./page/3/">Next &amp;raquo;</a>
  </nav>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="./archives/2020/08/">August 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E9%93%BE%E8%A1%A8/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E6%A0%88%E4%B8%8E%E9%98%9F%E5%88%97/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B9%8B%E6%95%B0%E7%BB%84/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE/">(no title)</a>
          </li>
        
          <li>
            <a href="./2020/08/07/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/SpringBoot%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">(no title)</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 xiaxuchen<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="./" class="mobile-nav-link">Home</a>
  
    <a href="./archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="./fancybox/jquery.fancybox.css">

  
<script src="./fancybox/jquery.fancybox.pack.js"></script>




<script src="./js/script.js"></script>




  </div>
</body>
</html>